//
//  SelectItemView.m
//  BMW
//
//  Created by up72-2 on 15/10/26.
//  Copyright © 2015年 up72-2. All rights reserved.
//

#import "SelectItemView.h"

@implementation SelectItemView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatUI];
    }
    return self;
}

- (void)creatUI
{
    NSArray *arr = [NSArray arrayWithObjects:@"用户名",@"版本更新",@"注   销", nil];
    
    for (int i=0; i<arr.count; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(0, 23*i, 120, 23);
        button.titleLabel.font = [UIFont systemFontOfSize:13];
        button.tag = i+10;
        [button setTitle:[arr objectAtIndex:i] forState:0];
        [button setTitleColor:[UIColor blackColor] forState:0];
        [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
    }
    
    //分割线
    for (int i=0; i<3; i++) {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 23+23*i, 120, 1)];
        view.backgroundColor = [UIColor blackColor];
        [self addSubview:view];
    }
}

// 1:用户 2：离线 3：版本 4：注销
- (void)buttonClick:(UIButton *)sender
{
    switch (sender.tag-10) {
        case 0:
            {
                self.backStr(@"1");
            }
            break;
            
        case 1:
            {
                self.backStr(@"2");
            }
            break;
        case 2:
            {
                self.backStr(@"3");
            }
            break;
        case 3:
            {
                self.backStr(@"4");
            }
            break;
            
        default:
            break;
    }
}

@end
